package com.demo.designmode.combination;

/**
 * @Author: jxm
 * @Description: 菜单组件  不管是菜单还是菜单项，都应该继承该类
 * @Date: 2023-11-17 10:07
 * @Version: 1.0
 */
public abstract class MenuComponent {

    //菜单组件的名称
    protected String name;
    //菜单组件的层级
    protected int level;

    //添加菜单
    public void add(MenuComponent menuComponent){
        throw new UnsupportedOperationException();
    }

    //移除菜单
    public void remove(MenuComponent menuComponent){
        throw new UnsupportedOperationException();
    }

    //获取指定的子菜单
    public MenuComponent getChild(int index){
        throw new UnsupportedOperationException();
    }

    //获取菜单名称
    public String getName(){
        return name;
    }

    //打印菜单名称方法（包含子菜单和菜单项）
    public abstract void print();
}
